﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Petaframe.DataAccess
{
    class TableParameterCommand : IDisposable , ICommandBuilder
    {
        Func<DataTable, int> _callback;
        DataTable _table;
        public TableParameterCommand(DataTable table, Func<DataTable, int> callback)
        {
            _table = table;
            _callback = callback;
        }

        public void Execute()
        {
            _callback(_table);
        }
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
                if (_table != null)
                {
                    _table.Dispose();
                    _table = null;
                    _callback=null;
                }
        }
        ~TableParameterCommand()
        {
            Dispose(false);
        }
    
    }
}
